﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title>Test</title>
        <style type="text/css">
        #introduction
        {
            background-color: #e1e1e1;
            font-size: 12px;
            margin: 5px;
            padding: 5px;
            clear: both;
        }
        </style>
		<script type="text/javascript">
        var dojoConfig = {
            baseUrl: "",
            tlmSiblingOfDojo: false,
            //packages: [
                //{ "name": "jquery", "location": 'modules', main: 'jquery-3.3.1.min' },
            //    { "name": "axios", "location": "modules", main: "axios.min" },
            //],
            paths: {
                'axios': 'modules/axios.min',
                'jquery': 'modules/jquery-3.3.1.min',
                'jquery.cookie': 'modules/jquery.cookie'
            },
            shim: {
                'jquery.cookie': { 'deps': ['jquery'] }
            }
        };
		</script>
		<script data-dojo-config="async: true" src="dojo.js"></script>
		
    </head>
    <body>
		<p>用户名： <input type="text" id="username" value="wyh" />
		密码： <input type="text" id="userpass" value="111111" />
        <input type="button" id="testauth" value="用户登录"/> <div id='jg'></div>
		<p>
		
		<p>
			创建影像下载文件
			<button class="btn btn-primary" type="button" id="contentButton">链接</button>
			<input type="text" class="form-control" size="88" value="{'CalculationType':'CBYD','GrassId':['152500-003-2018','152500-017-2018','152500-007-2018']}" id="messageText">
            <button class="btn btn-primary" type="button" id="messageButton">发送</button></br>
			<progress max="100" value="0" id="pg"></progress>
			<div class="col-lg-8" id="mainThread">
                  <h2>Discussion</h2>
              </div>
		</p>
    </body>
	<script type="text/javascript">
        require([
        "jquery",
        'modules/ApiClient',
		'modules/erstools',
		'modules/config',
		'modules/RasterImages',
		 "dojo/dom","dojo/on", "dojo/domReady!"
		], function ($,ApiClient,erstools,config,RasterImages,dom,on) {
			var tokenid = "";
			var stoken = "";
			$("#testauth").bind('click', function () {
                alert('zzh');
				var json_params={
					UserName:$("#username").val(),
					PasswordHash:$("#userpass").val()//,
					//client_id:'password_client'//'password_client'
				}
				alert(config.USWEBAPI);
				ApiClient.post(config.USWEBAPI+'Auth/login',json_params,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						$('#jg').append("登陆状态: "+reValues.data.reMessage+"<br/>");
						$('#jg').append("token: "+reValues.data.jwt+"<br/>");
						$('#jg').append("token-id: "+reValues.data.sid+"<br/>");
						tokenid = reValues.data.sid;
						stoken = reValues.data.jwt;
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
            });
			
			on(dom.byId("contentButton"),"click",function(evt){
				RasterImages.init();
			});
			on(dom.byId("messageButton"),"click",function(evt){
				var ydid = dom.byId("messageText").value;
				RasterImages.sendMessage(stoken);
				var pg=document.getElementById('pg');
				/*setInterval(function(e){
					if(pg.value!=100) pg.value++;
					else pg.value=0;
				},100);*/
			});
			
		});
	</script>
</html>